package com.lagou.sqlsession;

import com.lagou.config.Configuration;
import com.lagou.builder.XmlConfigBuilder;

import java.io.InputStream;

/**
 * 用于创建SqlSeesionFactoryBuilder
 * 这个类会解析配置文件封装到容器对象中
 * @author shenguotao
 */
public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream in) throws Exception {
        //1.解析配置文件，封装到Configuration
        XmlConfigBuilder parser = new XmlConfigBuilder();
        Configuration configuration = parser.parseConfig(in);
        //3.返回sqlSessionFactory
        return new DefaultSqlSessionFactory(configuration);
    }
}
